package view.equipe;

import java.awt.Color;
import java.awt.Dimension;
import java.util.Observable;
import java.util.Observer;

import javax.swing.BorderFactory;
import javax.swing.JLabel;

import server.models.tireur.ITireur;


public class TireurView extends JLabel implements Observer {

	private static final long serialVersionUID = 1L;

	public TireurView(ITireur tireur) {
		super(tireur.getSurnom());

		((Observable)tireur).addObserver(this);
        
		initialiseGraphic();
		this.setText(tireur.getParticipant().getSurnom());
	}

	private void initialiseGraphic() {
		this.setPreferredSize(new Dimension(100, 100));
		this.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		this.setVerticalAlignment(CENTER);
		this.setHorizontalAlignment(CENTER);
		this.repaint();
		this.setVisible(true);
	}
	
	@Override
	public void update(Observable tireur, Object arg1) {
		this.setText(((ITireur)tireur).getSurnom());
		this.repaint();
	}
}
